from django.db import models

# 1. 添加存储省市区三级数据的模型 Area
class Area(models.Model):
    name = models.CharField('地区名称', max_length=20)
    parent = models.ForeignKey(
        'self', related_name='subs',
        on_delete=models.CASCADE, verbose_name='上级地区', null=True, blank=True)

    class Meta:
        db_table = 'tb_areas'
        verbose_name = '省市区'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
